Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Add Style and Quality Parameters Support with Execution Settings #4

Conversation

aghimir3
Copy link

Motivation and Context

  1. Why is this change required?
    This change is required to introduce the use of style and quality parameters in image generation, along with the usage of OpenAITextToImageExecutionSettings within the OpenAITextToImageService.

  2. What problem does it solve?
    The implementation enables the OpenAITextToImageService to handle additional parameters (style and quality), allowing for more customized image generation requests. It also streamlines the integration with OpenAITextToImageExecutionSettings, making the service more flexible and configurable.

  3. What scenario does it contribute to?
    This contributes to scenarios where users need to generate images with specific styles and qualities, enhancing the functionality and usability of the OpenAITextToImageService.

  4. If it fixes an open issue, please link to the issue here.
    This implementation fixes issue #7086 and #5657

Description

This PR enhances the OpenAITextToImageService by:

  • Introducing Style and Quality Parameters: The service now supports the style and quality parameters, allowing users to generate images with specific artistic styles and quality levels.
  • Integration with OpenAITextToImageExecutionSettings: The service now utilizes OpenAITextToImageExecutionSettings for handling execution parameters, improving the overall flexibility and configurability of image generation requests.
  • Validation: Added validation for the style and quality parameters to ensure only supported values are used.
  • Unit Testing: Comprehensive tests have been added to verify the correct handling of style and quality parameters, as well as the general functionality of the service with various settings.

Contribution Checklist

- Added the GetImageContentsAsync method to the OpenAITextToImageService class.
- Implemented validation for input, including width, height, quality, and style settings.
- Supported image sizes include 256x256, 512x512, 1024x1024, 1792x1024, and 1024x1792.
- Added checks for supported qualities ('standard', 'hd') and styles ('vivid', 'natural').
- Constructed the request body for image generation and processed the response to handle both URLs and base64-encoded images.
- Converted image strings into ImageContent objects, ensuring proper handling of data URIs and HTTP URLs.
- Implemented unit tests for the GetImageContentsAsync method in OpenAITextToImageService.
- Added a test to verify that the method returns expected ImageContent when provided with valid input.
- Added parameterized tests using [Theory] and [InlineData] to cover a variety of scenarios:
  - Valid URL and base64 image data inputs.
  - Validation of input sizes, quality, and style parameters.
  - Ensured NotSupportedException is thrown for unsupported sizes, quality, and style.
- Tests ensure that both HTTP URLs and base64-encoded images are handled correctly, with proper assertions on the returned ImageContent objects.
@aghimir3 aghimir3 changed the title Issues/5657 itexttoimage ag Add Style and Quality Parameters Support with Execution Settings Aug 14, 2024
@aghimir3 aghimir3 changed the title Add Style and Quality Parameters Support with Execution Settings .NET Add Style and Quality Parameters Support with Execution Settings Aug 14, 2024
@aghimir3
Copy link
Author

@RogerBarreto PR ready :)

@RogerBarreto
Copy link
Owner

Thanks for the contribution @aghimir3 !

@RogerBarreto RogerBarreto merged commit 9a47d7c into RogerBarreto:issues/5657-itexttoimage-update Aug 14, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants